-module(g_service).
-export([get_active_code/1,confirm_code/1]).

get_active_code(L) ->
	{html,
	case tools:get_param(L,"mobile",undefined) of
	undefine ->
		"invalid mobile number";
	Mobile ->
		case gen_server:call(confirm_service,{send_sms,Mobile}) of
		{ok,RN} ->
			RN;
		_ ->
			"系统繁忙"
		end 
	end}.

confirm_code(L) ->
	{html,
	case {tools:get_param(L,"mobile",""),tools:get_param(L,"code","")} of
	{"",_} ->
		"error";
	{_,""} ->
		"error";
	{Mobile,Code} ->
		case gen_server:call(confirm_service,{confirm,Mobile,Code}) of
		true ->
			"ok";
		false ->
			"error"
		end
	end}.
